import 'package:flutter/material.dart';
import '../form.dart';
import '../../components/myDialog.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List<Widget> _getData(){
    List<Widget> list = new List();
    for(int i=0;i<30;i++){
      list.add(ListTile(
        title: Text('首页$i'),
        leading: CircleAvatar(
          backgroundImage: NetworkImage('https://www.itying.com/images/flutter/2.png'),
        ),
        subtitle: Text('副标题$i'),
      ));
    }
    return list.toList();
  }

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Container(
        width: double.infinity,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            SizedBox(height: 10,),
            RaisedButton(
              child: Text('跳转到搜索页面'),
              color: Colors.orange,
              onPressed: (){
                // 命名路由-适合大型项目
                Navigator.pushNamed(context, '/search', arguments: {
                  'id': 123
                });
              },
            ),
            RaisedButton(
              child: Text('跳转到表单页面并传值'),
              color: Colors.green,
              onPressed: (){
                // 路由跳转-适合小型项目
                Navigator.of(context).push(
                    MaterialPageRoute(
                        builder: (context) => FormPage(title: '哈哈哈哈',)
                    )
                );
              },
            ),
            RaisedButton(
              child: Text('appbarDemo'),
              color: Colors.orange,
              onPressed: (){
                Navigator.pushNamed(context, '/appbarDemo');
              },
            ),
            RaisedButton(
              child: Text('TabControllerPage'),
              color: Colors.orange,
              onPressed: (){
                Navigator.pushNamed(context, '/tabController');
              },
            ),
            RaisedButton(
              child: Text('Buttons'),
              color: Colors.blue,
              onPressed: (){
                Navigator.pushNamed(context, '/buttons');
              },
            ),
            RaisedButton(
              child: Text('TextField'),
              onPressed: (){
                Navigator.pushNamed(context, '/textField');
              },
            ),
            RaisedButton(
              child: Text('checkbox'),
              onPressed: (){
                Navigator.pushNamed(context, '/checkbox');
              },
            ),
            RaisedButton(
              child: Text('radio & switch'),
              onPressed: (){
                Navigator.pushNamed(context, '/radio');
              },
            ),
            RaisedButton(
              child: Text('formDemo综合'),
              color: Colors.red,
              textColor: Colors.white,
              onPressed: (){
                Navigator.pushNamed(context, '/formDemo');
              },
            ),
            RaisedButton(
              child: Text('日期组件'),
              color: Colors.red,
              textColor: Colors.white,
              onPressed: (){
                Navigator.pushNamed(context, '/datePickerPage');
              },
            ),
            RaisedButton(
              child: Text('第三方日期组件'),
              color: Colors.red,
              textColor: Colors.white,
              onPressed: (){
                Navigator.pushNamed(context, '/cupertinoDatePickerPage');
              },
            ),
            RaisedButton(
              child: Text('swiper'),
              color: Colors.red,
              textColor: Colors.white,
              onPressed: (){
                Navigator.pushNamed(context, '/swiperPage');
              },
            ),
            RaisedButton(
              child: Text('alert & dialog'),
              color: Colors.red,
              textColor: Colors.white,
              onPressed: (){
                Navigator.pushNamed(context, '/alertDialogPage');
              },
            ),
            RaisedButton(
              child: Text('自定义dialog'),
              color: Colors.green,
              textColor: Colors.white,
              onPressed: (){
                showDialog(context: context, builder: (context) {
                  return MyDialog(
                      title: '提示',
                      content: '传入的内容',
                      duration: 3000
                  );
                });
              },
            ),
            RaisedButton(
              child: Text('Http网络请求'),
              color: Colors.red,
              textColor: Colors.white,
              onPressed: (){
                Navigator.pushNamed(context, '/httpPage');
              },
            ),
          ],
        ),
      ),
    );

    /*return ListView(
      children: this._getData(),
    );*/
  }
}

